package org.training.person.mason.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;


import com.google.appengine.api.datastore.Blob;
import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class UserInfo implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4434638448451792887L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key userId;
	@Persistent
	private String UserName;
	@Persistent
	private String UserPass;
	@Persistent
	private String Name;
	@Persistent
	private Date UserBirth;
	@Persistent
	private Blob UserPhoto;
	@Persistent
	private Set<Key> UserEducations;
	@Persistent
	private Set<Key> UserContacts;
	@Persistent
	private Set<Key> UserRelationShips;
	@Persistent
	private Set<Key> UserResources;

	/**
	 * The Default Constructor of UserInfo;
	 */
	public UserInfo() {
	}

	/**
	 * @param userName
	 * @param userPass
	 * @param name
	 * @param userBirth
	 */
	public UserInfo(String userName, String userPass, String name,
			Date userBirth) {
		super();
		UserName = userName;
		UserPass = userPass;
		Name = name;
		UserBirth = userBirth;
	}

	/**
	 * @return the userId
	 */
	public Key getUserId() {
		return userId;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return Name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		Name = name;
	}

	/**
	 * @return the userBirth
	 */
	public Date getUserBirth() {
		return UserBirth;
	}

	/**
	 * @param userBirth
	 *            the userBirth to set
	 */
	public void setUserBirth(Date userBirth) {
		UserBirth = userBirth;
	}

	/**
	 * @return the userName
	 */
	public String getUserName() {
		return UserName;
	}

	/**
	 * @param userName
	 *            the userName to set
	 */
	public void setUserName(String userName) {
		UserName = userName;
	}

	/**
	 * @return the userPass
	 */
	public String getUserPass() {
		return UserPass;
	}

	/**
	 * @param userPass
	 *            the userPass to set
	 */
	public void setUserPass(String userPass) {
		UserPass = userPass;
	}

	/**
	 * @return the userPhoto
	 */
	public Blob getUserPhoto() {
		return UserPhoto;
	}

	/**
	 * @param userPhoto
	 *            the userPhoto to set
	 */
	public void setUserPhoto(Blob userPhoto) {
		UserPhoto = userPhoto;
	}

	/**
	 * @return the userEducations
	 */
	public Set<Key> getUserEducations() {
		return UserEducations;
	}

	/**
	 * @return the userContacts
	 */
	public Set<Key> getUserContacts() {
		return UserContacts;
	}

	/**
	 * @return the userRelations
	 */
	public Set<Key> getUserRelations() {
		return UserRelationShips;
	}

	/**
	 * @return the userResources
	 */
	public Set<Key> getUserResources() {
		return UserResources;
	}

	/**
	 * @param edu
	 */
	public void addEducation(Education edu) {
		UserEducations.add(edu.getEducationId());
	}

	/**
	 * @param edus
	 */
	public void addEducations(List<Education> edus) {
		for (Education edu : edus) {
			UserEducations.add(edu.getEducationId());
		}
	}

	/**
	 * 
	 * @param contact
	 */
	public void addContact(Contact contact) {
		UserContacts.add(contact.getContactId());
	}

	/**
	 * 
	 * @param contacts
	 */
	public void addContacts(List<Contact> contacts) {
		for (Contact contact : contacts) {
			UserContacts.add(contact.getContactId());
		}
	}

	/**
	 * 
	 * @param relationShip
	 */
	public void addRelationShip(RelationShip relationShip) {
		UserRelationShips.add(relationShip.getRelationId());
	}

	/**
	 * 
	 * @param relationShips
	 */
	public void addRelationShips(List<RelationShip> relationShips) {
		for (RelationShip relationShip : relationShips) {
			UserRelationShips.add(relationShip.getRelationId());
		}
	}

	/**
	 * 
	 * @param resource
	 */
	public void addResource(Resource resource) {
		UserResources.add(resource.getResourceId());
	}

	/**
	 * 
	 * @param resources
	 */
	public void addResources(List<Resource> resources) {
		for (Resource resource : resources) {
			UserResources.add(resource.getResourceId());
		}
	}
}
